package com.zh.freechat.common.req;

import jakarta.validation.Valid;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import lombok.Data;
import org.hibernate.validator.constraints.Length;

import java.io.Serializable;
import java.util.List;

/**
 * @author Zhou
 * @date 19:38 2024/4/23
 */
@Data
public class GroupForm implements Serializable {

    @NotEmpty(message = "群名称不能为空")
    private String name;
    private String avatar;
    @NotEmpty(message = "群用户不能为空")
    @Size(min = 2,max = 500,message = "群用户数量不能超出2-500范围")
    private List<MemberItem> users;

    private String ownerUid;

    @Valid
    @Data
    public static class MemberItem implements Serializable{

        @NotNull(message = "用户ID不能为空")
        private String userId;

        @Length(max = 50,message = "在群中的别名长度不能>50")
        private String aliasName;

        /**
         * 当单独添加成员时，才需要群号参数
         */
        @Length(max = 50,message = "群号长度超出范围")
        private String groupNo;
    }
}
